﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using mBlog.Models;
using System.Text;

namespace mBlog.Infrastructure.AutoMapper
{
    public class TagResolver
    {
        public static string ResolveTagStrings(IList<Tag> tags )
        {
            StringBuilder tagString = new StringBuilder();
            foreach (var t in tags)
            {
                tagString.Append(t.Name).Append(",");
            }

            return tagString.ToString();
        }

        public static  IEnumerable<Tag> ResolveTags(string tagString)
        {
            IList<string> ts = tagString.Split(',');
            return (from t in ts
                    select new Tag()
                               {
                                   Name = t,
                                   UrlName = t
                               }).ToList();

        }
    }
}